package com.controller;

import com.model.User;
import com.service.UserService;
import com.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/elm/UserController")
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping("/getUserByIdByPass")
    public Object getUserByIdByPass(String userId, String password) throws Exception{
        User userByIdByPass = userService.getUserByIdByPass(userId, password);
        return userByIdByPass;
    }
    @RequestMapping("/getUserById")
    public Object getUserById(String userId)throws Exception{
        UserServiceImpl userService = new UserServiceImpl();
        int userById = userService.getUserById(userId);
        return  userById;
    }
    @RequestMapping("/saveUser")
    public Object saveUser(String userId, String password,String userName,int userSex )throws  Exception{
        UserServiceImpl userService = new UserServiceImpl();
        int i = userService.saveUser(userId, password, userName, userSex);
        return i;
    }
}
